<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="tong.li&#39;s blog">
  <meta name="keyword" content="彤哥哥博客，95后技术爱好者,现就职于同程旅行/同程艺龙上海分公司，专注于互联网技术分享的平台。">
  
    <link rel="shortcut icon" href="/css/images/icon.png">
  
  <title>
    
      RabbitMQ概述 | 彤哥哥的博客
    
  </title>
  <link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="https://cdn.staticfile.org/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="https://cdn.staticfile.org/highlight.js/9.12.0/styles/tomorrow-night.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="https://cdn.staticfile.org/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
  
  
    <!-- MathJax support START -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="https://cdn.staticfile.org/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <!-- MathJax support END -->
  


  
  
    
<script src="/js/local-search.js"></script>


<meta name="generator" content="Hexo 5.4.2"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>
  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>彤哥哥的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/series/" class="item-link">分类</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/project/" class="item-link">项目</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于</a>
          
        </li>
      
      
        <li class="menu-item menu-item-search right-list">
    <a role="button" class="popup-trigger">
        <i class="fa fa-search fa-fw"></i>
    </a>
</li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/series/" class="menu-link">分类</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/project/" class="menu-link">项目</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于</a>
            
          </li>
        
      </ul>
    </div>
    
      <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
            <span class="search-icon">
                <i class="fa fa-search"></i>
            </span>
            <div class="search-input-container">
                <input autocomplete="off" autocapitalize="off"
                    placeholder="Please enter your keyword(s) to search." spellcheck="false"
                    type="search" class="search-input">
            </div>
            <span class="popup-btn-close">
                <i class="fa fa-times-circle"></i>
            </span>
        </div>
        <div id="search-result">
            <div id="no-result">
                <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
            </div>
        </div>
    </div>
</div>
    
  </div>
</header>

    <div id="article-banner">
  <h2>RabbitMQ概述</h2>
  <p class="post-date">2018-06-11</p>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><p>之所以今天写RabbitMQ学习专栏，主要是因为自己没有真正的系统学习过。之前工作经历中都是为用MQ而用的MQ，对MQ整个内部机制没有一个深入的了解和系统的学习。比如我们用Spring Cloud Stream或Spring Cloud Bus组件时候，我们会经常碰到MQ。MQ产品市面上有很多种，不同MQ产品有不同的适应场景(领域)。这就和学什么语言一样，不分什么好坏。</p>
<p>在这我要插上一句，在讨论技术选型的时候，我经常听到很多人说哪种技术好，哪种技术坏，哪种技术流行，哪种技术淘汰。其实正解应该是每种技术方案有自己适应领域，存在即合理。面试的时候经常有面试官询问技术方案选型。什么Spring Cloud和Dubbo比（压根就不是一个领域，Spring Cloud是整套的微服务落地方案，Dubbo只是一个具有客户端负载均衡的高性能RPC框架，论功能Dubbo只是Spring Cloud的一个子集），什么Redis和MongoDB比，ES和Solr比，各种MQ的比较，其实我觉得问这些面试题是有局限性的，没有具体业务场景就是无解，具体选型还是要根据当前公司的现有业务和系统现状来选型。我觉得面试官应该先把公司的业务场景说出来，然后应聘者根据公司的业务进行客观性评定。</p>
<p>好了，言归正传，常见的高级的MQ产品有RabbitMQ、Apache ActiveMQ、Apache RocketMQ(Alibaba捐赠)、Apache Kafka(LinkedIn捐赠) 。那么，今天我这里选择RabbitMQ进行学习，其他MQ学习都是相通的，读者可根据自身情况阅读官网文档并进行学习。我这里只是介绍一种学习方式。下面从官方文档以及其他资料给大家进行梳理RabbitMQ系列的知识。</p>
<h2 id="MQ消息队列"><a href="#MQ消息队列" class="headerlink" title="MQ消息队列"></a>MQ消息队列</h2><h3 id="MQ概述"><a href="#MQ概述" class="headerlink" title="MQ概述"></a>MQ概述</h3><p>消息队列技术是分布式应用间交换信息的一种技术。</p>
<p>消息队列可驻留在内存或磁盘上,队列存储消息直到它们被应用程序读走。</p>
<p>通过消息队列，应用程序可独立地执行。它们不需要知道彼此的位置、或在继续执行前不需要等待接收程序接收此消息。</p>
<p>MQ主要作用是接受和转发消息。你可以想想在生活中的一种场景：当你把信件的投进邮筒，邮递员肯定最终会将信件送给收件人。我们可以把MQ比作 邮局和邮递员。</p>
<p>MQ和邮局的主要区别是,它不处理消息,但是,它会接受数据、存储消息数据、转发消息。</p>
<h3 id="MQ应用场景"><a href="#MQ应用场景" class="headerlink" title="MQ应用场景"></a>MQ应用场景</h3><ul>
<li><p>应用解耦: 系统异步化改造；</p>
<ol>
<li>用户注册后的邮件发送、验证码短信发送；</li>
<li>分布式延时队列应用，用户下单后，24小时未支付，需要取消订单，我们只需要下单时用MQ发个消息通知一下，客户端延时（下单时间24小时后）执行，消费成功则证明取消订单成功。</li>
</ol>
</li>
<li><p>异步通知及数据同步: 提升系统性能，保证数据最终一致性；</p>
<ol>
<li>用户在管理页面更新数据，通过MQ异步通知，更新缓存、更新ES或Solr索引</li>
</ol>
</li>
<li><p>应用限流: 可以保证并发场景下系统的稳定性；</p>
<ol>
<li>抢票系统，在并发大系统有瓶颈的情况下，可以将请求打到MQ队列依次限流消费。</li>
<li>分布式日志系统数据很大的时候，MQ作为分布式日志的缓冲层，典型应用就是ELK+Kafaka。</li>
</ol>
</li>
<li><p>数据分发: 一对多或广播的模式进行数据分发；</p>
<ol>
<li>支付完成后，需要及时的通知子系统（进销存系统发货，用户服务积分，发送短信）</li>
</ol>
</li>
<li><p>分布式事务: 分布式架构的系统可以通过MQ的队列数据进行数据回滚操作</p>
</li>
</ul>
<h2 id="RabbitMQ产品介绍"><a href="#RabbitMQ产品介绍" class="headerlink" title="RabbitMQ产品介绍"></a>RabbitMQ产品介绍</h2><h3 id="RabbitMQ产品"><a href="#RabbitMQ产品" class="headerlink" title="RabbitMQ产品"></a>RabbitMQ产品</h3><p>打开RabbitMQ官网首页，能看到如下的一句话:</p>
<blockquote>
<p>RabbitMQ is the most widely deployed open source message broker.</p>
</blockquote>
<p>翻译为：RabbitMQ是部署最广泛的开源消息代理。</p>
<p>RabbitMQ是一个Erlang开发的AMQP（Advanced Message Queuing Protocol ）的开源实现。AMQP 的出现其实也是应了广大人民群众的需求，虽然在同步消息通讯的世界里有很多公开标准（如 Cobar）的 IIOP ，或者是 SOAP 等），但是在异步消息处理中却不是这样，只有大企业有一些商业实现（如微软的 MSMQ ，IBM 的 WebSphere MQ 等），因此，在 2006 年的 6 月，Cisco 、Red Hat、iMatix 等联合制定了 AMQP 的公开标准。</p>
<p>RabbitMQ由RabbitMQ Technologies Ltd开发并且提供商业支持的。该公司在2010年4月被SpringSource（VMware的一个部门）收购。在2013年5月被并入Pivotal。其实VMware，Pivotal和EMC本质上是一家的。不同的是，VMware是独立上市子公司，而Pivotal是整合了EMC的某些资源，现在并没有上市。</p>
<h3 id="RabbitMQ产品特性"><a href="#RabbitMQ产品特性" class="headerlink" title="RabbitMQ产品特性"></a>RabbitMQ产品特性</h3><ul>
<li>开源免费；</li>
<li>可伸缩性：集群服务；</li>
<li>消息持久化：从内存持久化消息到硬盘，再从硬盘加载到内存；</li>
<li>多语言多客户端支持，支持Python、Java、Ruby、PHP、C#、JavaScript、Go、Elixir、Objective-C、Swift、Spring AMQP。</li>
</ul>
<h3 id="RabbitMQ常用模式"><a href="#RabbitMQ常用模式" class="headerlink" title="RabbitMQ常用模式"></a>RabbitMQ常用模式</h3><p>打开<a target="_blank" rel="noopener" href="https://www.rabbitmq.com/getstarted.html">官方文档</a>，我们眼前一亮，会看到如下6种RabbitMQ的工作模式：</p>
<table>
<thead>
<tr>
<th align="left">1. <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-one-python.html">“Hello World!”</a><br/> The simplest thing that does <em>something</em> <img src="https://ltyeamin.github.io/imgs/2020/07/20200731170602.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-one-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-one-spring-amqp.html">Spring AMQP</a></th>
<th align="left">2. <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-two-python.html">Work queues</a><br/> Distributing tasks among workers (the <a target="_blank" rel="noopener" href="http://www.enterpriseintegrationpatterns.com/patterns/messaging/CompetingConsumers.html">competing consumers pattern</a>)<img src="https://ltyeamin.github.io/imgs/2020/07/20200731170612.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-two-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-two-spring-amqp.html">Spring AMQP</a></th>
<th>3. <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-three-python.html">Publish/Subscribe</a><br/> Sending messages to many consumers at once<img src="https://ltyeamin.github.io/imgs/2020/07/20200731170619.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-three-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-three-spring-amqp.html">Spring AMQP</a></th>
</tr>
</thead>
<tbody><tr>
<td align="left">4. <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-four-python.html">Routing</a><br/>Receiving messages selectively<img src="https://ltyeamin.github.io/imgs/2020/07/20200731170637.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-four-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-four-spring-amqp.html">Spring AMQP</a></td>
<td align="left">5.  <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-five-python.html">Topics</a><br/> The simplest thing that does <em>something</em> <img src="https://ltyeamin.github.io/imgs/2020/07/20200731170632.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-five-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-five-spring-amqp.html">Spring AMQP</a></td>
<td>6. <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-six-python.html">RPC</a><br/> <a target="_blank" rel="noopener" href="http://www.enterpriseintegrationpatterns.com/patterns/messaging/RequestReply.html">Request/reply pattern</a>example<img src="https://ltyeamin.github.io/imgs/2020/07/20200731170625.png" alt="img">       <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-six-java.html">Java</a> <a target="_blank" rel="noopener" href="https://www.rabbitmq.com/tutorials/tutorial-six-spring-amqp.html">Spring AMQP</a></td>
</tr>
</tbody></table>
<p>看到上述的6种工作模式，其中我们日常使用最多的是前5种模式，我们列一个学习列表: </p>
<ul>
<li><a target="_blank" rel="noopener" href="http://www.baidu.com/">简单模式</a>: 一个生产者，一个消费者</li>
<li><a target="_blank" rel="noopener" href="http://www.baidu.com/">Work模式</a>: 一个生产者，多个消费者，每个消费者获取到的消息唯一。</li>
<li><a target="_blank" rel="noopener" href="http://www.baidu.com/">订阅模式</a>: 一个生产者发送的消息会被多个消费者获取。</li>
<li><a target="_blank" rel="noopener" href="http://www.baidu.com/">路由模式</a>: 发送消息到交换机并且要指定路由key ，消费者将队列绑定到交换机时需要指定路由key</li>
<li><a target="_blank" rel="noopener" href="http://www.baidu.com/">Topic模式</a>: 将路由键和某模式进行匹配，此时队列需要绑定在一个模式上，“#”匹配一个词或多个词，“*”只匹配一个词。</li>
<li><a href="">RPC远程调用</a>：几乎不用，暂时先不考虑</li>
</ul>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><ul>
<li><a target="_blank" rel="noopener" href="https://www.rabbitmq.com/getstarted.html">RabbitMQ官网快速入门文档</a></li>
<li><a target="_blank" rel="noopener" href="http://www.java1234.com/a/javabook/javabase/2018/0728/11620.html">《RabbitMQ实战指南》朱忠华著</a></li>
<li><a target="_blank" rel="noopener" href="https://my.oschina.net/u/3777556/blog/3035943">什么是消息队列</a></li>
</ul>
</section>
    <!-- Tags START -->
    
      <div class="tags">
        <span>Tags:</span>
        
  <a href="/tags#RabbitMQ" >
    <span class="tag-code">RabbitMQ</span>
  </a>

      </div>
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/2018/06/10/Docker%E5%AE%89%E8%A3%85%E5%88%86%E5%B8%83%E5%BC%8F%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6-RabbitMQ/">
        <span class="nav-arrow">← </span>
        
          Docker安装分布式消息中间件-RabbitMQ
        
      </a>
    
    
      <a class="nav-right" href="/2018/06/12/RabbitMQ%E5%B7%A5%E4%BD%9C%E6%A8%A1%E5%BC%8F%E4%B9%8B%E7%AE%80%E5%8D%95%E6%A8%A1%E5%BC%8F/">
        
          RabbitMQ工作模式之简单模式
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">若你觉得我的文章对你有帮助，欢迎点击上方按钮对我打赏</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Utterances START -->
      <div id="utterances"></div>
      <script src="https://utteranc.es/client.js"
        repo="ltyeamin/blogtalks"
        issue-term="pathname"
        theme="github-light"
        crossorigin="anonymous"
        async></script>    
      <!-- Utterances END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
    <strong class="toc-title">Catalog</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#MQ%E6%B6%88%E6%81%AF%E9%98%9F%E5%88%97"><span class="toc-nav-text">MQ消息队列</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#MQ%E6%A6%82%E8%BF%B0"><span class="toc-nav-text">MQ概述</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#MQ%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF"><span class="toc-nav-text">MQ应用场景</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#RabbitMQ%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D"><span class="toc-nav-text">RabbitMQ产品介绍</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#RabbitMQ%E4%BA%A7%E5%93%81"><span class="toc-nav-text">RabbitMQ产品</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#RabbitMQ%E4%BA%A7%E5%93%81%E7%89%B9%E6%80%A7"><span class="toc-nav-text">RabbitMQ产品特性</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#RabbitMQ%E5%B8%B8%E7%94%A8%E6%A8%A1%E5%BC%8F"><span class="toc-nav-text">RabbitMQ常用模式</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="toc-nav-text">参考资料</span></a></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://example.com/2018/06/11/RabbitMQ概述/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', '/css/images/error_icon.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== '/css/images/error_icon.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>






    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
  <p class="copyright">
    &copy; 2024 | Proudly powered by <a href="https://hexo.io" target="_blank">Hexo</a>
    <br>
    Theme by <a target="_blank" rel="noopener" href="https://github.com/ltyeamin">tong.li</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("https://cdn.staticfile.org/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("https://cdn.staticfile.org/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      hljs.configure({useBR: true});
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>
<!-- Baidu Tongji -->



<script src='https://cdn.staticfile.org/mermaid/8.11.2/mermaid.min.js'></script>



<script src="/js/script.js"></script>


  </body>
</html>